package com.hgkj.cloud.base.scheme.table;

import com.hgkj.cloud.base.scheme.ClsAnswerRequest;
import com.hgkj.cloud.base.scheme.ClsAnswerResult;
import com.hgkj.cloud.base.scheme.ClsScore;

import java.util.Map;

/**
 *一百二十七、中学生心理健康综合测量(Zxxljkzh)，共100题，10个因子，2个选项
 */
public class Table127 extends AbstractTable implements TableCalculate{
    String code = "";

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public ClsAnswerResult calc(ClsAnswerRequest answer) {
        return null;
    }

    @Override
    public String[] report(Map map) {
        return null;
    }
    
	
	private static ClsAnswerResult GetZxxljkzhFactorScore(ClsAnswerRequest answer) {
		// 1总分，2学习焦虑，3对人焦虑，4孤独倾向，5自责倾向，6过敏倾向，7身体症状，8恐怖倾向，9冲动倾向，10掩饰分
		ClsAnswerResult result = new ClsAnswerResult();
		result.setMessage("");
		result.setType(answer.getType());
		result.setUuid(answer.getUuid());
		try {
			// 1正确题数
			int MAX_NUM = 100;

			int intI;
			String[] strAnswer_c = answer.getAnswer().split(g_sChar);
			if (strAnswer_c.length > 1) {
				for (intI = 1; intI < strAnswer_c.length; intI++) {
					strAnswer_c[intI] = strAnswer_c[intI].trim();
				}
			}

			String[] strChildAnswerA = strAnswer_c[0].toString().split(g_nChar);

			if (strChildAnswerA.length != MAX_NUM) {
				result.setMessage("答案数量不符！");
				return result;
			}

			int i, j;

			// 共1组，1,0
			String[] strNumberA = { "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15", "16,17,18,19,20,21,22,23,24,25",
					"26,27,28,29,30,31,32,33,34,35", "36,37,38,39,40,41,42,43,44,45", "46,47,48,49,50,51,52,53,54,55",
					"56,57,58,59,60,61,62,63,64,65,66,67,68,69,70", "71,72,73,74,75,76,77,78,79,80",
					"81,83,85,87,89,91,93,95,97,99", "82,84,86,88,90,92,94,96,98,100" };
			String[] strSubA;

			float[] vFactorA = new float[10]; // 实际为10个因子
			String[] vDoctorIdeaA = new String[10]; // 指导意见

			for (i = 0; i < vFactorA.length; i++) {
				vFactorA[i] = 0;
				vDoctorIdeaA[i] = "";
			}

			for (i = 0; i < strNumberA.length; i++) {
				strSubA = strNumberA[i].split(",");
				for (j = 0; j < strSubA.length; j++) {
					vFactorA[i + 1] += 2 - Integer.valueOf(strChildAnswerA[Integer.valueOf(strSubA[j]) - 1]);
				}
				if (i != strNumberA.length - 1) {
					vFactorA[0] += vFactorA[i + 1]; // 总分
				}
			}

			// 诊断结果，“掩饰分”没有
			int[][] arrNum = { { 65, 56 }, { 8, 4 }, { 8, 4 }, { 8, 4 }, { 8, 4 }, { 8, 4 }, { 8, 4 }, { 8, 4 },
					{ 8, 4 } };
			for (i = 0; i < arrNum.length; i++) {
				vDoctorIdeaA[i] = "Zxxljkzh." + String.valueOf(i + 1) + ".3";
				for (j = 0; j < arrNum[0].length; j++) {
					if (vFactorA[i] >= arrNum[i][j]) {
						vDoctorIdeaA[i] = "Zxxljkzh." + String.valueOf(i + 1) + "." + String.valueOf(j + 1);
						break;
					}
				}
			}

			ClsScore.Zxxljkzh zxxljkzh = new ClsScore.Zxxljkzh();

			zxxljkzh.setTotal_o(vFactorA[0]);
			zxxljkzh.setTotal_d(vDoctorIdeaA[0]);

			zxxljkzh.setXx_o(vFactorA[1]);
			zxxljkzh.setXx_d(vDoctorIdeaA[1]);

			zxxljkzh.setDr_o(vFactorA[2]);
			zxxljkzh.setDr_d(vDoctorIdeaA[2]);

			zxxljkzh.setGd_o(vFactorA[3]);
			zxxljkzh.setGd_d(vDoctorIdeaA[3]);

			zxxljkzh.setZz_o(vFactorA[4]);
			zxxljkzh.setZz_d(vDoctorIdeaA[4]);

			zxxljkzh.setGm_o(vFactorA[5]);
			zxxljkzh.setGm_d(vDoctorIdeaA[5]);

			zxxljkzh.setSt_o(vFactorA[6]);
			zxxljkzh.setSt_d(vDoctorIdeaA[6]);

			zxxljkzh.setKb_o(vFactorA[7]);
			zxxljkzh.setKb_d(vDoctorIdeaA[7]);

			zxxljkzh.setCd_o(vFactorA[8]);
			zxxljkzh.setCd_d(vDoctorIdeaA[8]);

			zxxljkzh.setYs_o(vFactorA[9]);

			result.setObject(zxxljkzh);
			return result;
		} catch (ArithmeticException e) {
			result.setMessage(e.toString());
			return result;
		}
	}


}
